<If Loop>
   <IsFKey>
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using <Application>.Models;

   <ExitLoop>
</If Loop>
namespace <Application>.Data
{

<If Loop>
   <IsFKey>
    public class <TableU>_<RTableU>Data
    {
        public static DataTable SelectAll()
        {
            SqlConnection connection = <Database>Data.GetConnection();
            string selectStatement 
                = "SELECT "  
                <IsFKey>
                + "     [<RField>] " 
                <IsFKey>
                <And>
                <IsRDisplayField>
                + "    ,[<RDisplayField>] " 
                <IsFKey>
                + "FROM " 
                + "     [<ROwner>].[<RTable>] " 
                <IsFKey>
                + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);
            DataTable dt = new DataTable();
            try
            {
                connection.Open();
                SqlDataReader reader = selectCommand.ExecuteReader();
                if (reader.HasRows) {
                    dt.Load(reader); }
                reader.Close();
            }
            catch (SqlException)
            {
                return dt;
            }
            finally
            {
                connection.Close();
            }
            return dt;
        }

        public static List<<RTableU>> List()
        {
            List<<RTableU>> <RTableU>List = new List<<RTableU>>();
            SqlConnection connection = <Database>Data.GetConnection();
            string selectStatement 
                = "SELECT "  
                <IsFKey>
                + "     [<RField>] " 
                <IsFKey>
                <And>
                <IsRDisplayField>
                + "    ,[<RDisplayField>] " 
                <IsFKey>
                + "FROM " 
                + "     [<ROwner>].[<RTable>] " 
                <IsFKey>
                + "";
            SqlCommand selectCommand = new SqlCommand(selectStatement, connection);
            try
            {
                connection.Open();
                SqlDataReader reader = selectCommand.ExecuteReader();
                <RTableU> <RTableU> = new <RTableU>();
                while (reader.Read())
                {
                    <RTableU> = new <RTableU>();
                    <IsFKey>
                    <RTableU>.<RFieldU> = <Convert>(reader["<RField>"]);
                    <IsFKey>
                    <And>
                    <IsRDisplayField>
                    <RTableU>.<RDisplayFieldU> = Convert.ToString(reader["<RDisplayField>"]);
                    <IsFKey>
                    <RTableU>List.Add(<RTableU>);
                <IsFKey>
                }
                reader.Close();
            }
            catch (SqlException)
            {
                return <RTableU>List;
            }
            finally
            {
                connection.Close();
            }
            return <RTableU>List;
        }

    }

</If Loop>
}

